import { CHANGE_INPUT_VALUE, ADD_TASKS, REMOVE_TASKS, GET_TASK_LIST, GET_SAGA_TASK_LIST } from "./actionTypes";
import axios from "axios"

export const changeInputValueAction = (value) => {
  return {
    type: CHANGE_INPUT_VALUE,
    value,
  };
};

export const addTaskAction = () => {
  return {
    type: ADD_TASKS,
  };
};

export const removeTaskAction = (index) => {
  return {
    type: REMOVE_TASKS,
    index,
  };
};

// 获取任务列表
export const getTaskListAction = (list) => {
  return {
    type: GET_TASK_LIST,
    list
  }
}

// 获取任务列表 => (redux-thunk)
// export const getTaskThunkActions = () =>{
//   return (dispatch) => {
//     axios.get('https://www.fastmock.site/mock/21a510471fabc5e57f4ef5267cb2dbf5/reactRedux/taskList').then(response => {
//       const action = getTaskListAction(response.data)
//       dispatch(action)
//     })
//   }
// }

// 获取任务列表 => (redux-saga)
export const getTaskSagaActions = () =>{
  return {
    type: GET_SAGA_TASK_LIST
  }
}
